package com.blb.springboot.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blb.springboot.entity.User;
import com.blb.springboot.mapper.UserMapper;
import com.blb.springboot.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements UserService {

    @Resource
    private UserMapper userMapper;
    @Override
    public User selectUser(User user) {
        QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
        userQueryWrapper.eq("name",user.getName());
        userQueryWrapper.eq("password",user.getPassword());
        List<User> users = userMapper.selectList(userQueryWrapper);
        return users.get(0);
    }

    @Override
    public void insertUser(User user) {
        userMapper.insert(user);
    }
}
